//
//  WKStrategyListVC.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/21.
//  Copyright © 2018 何文虎. All rights reserved.
//

#import "WKStrategyListVC.h"
#import "WKTalkHomePageVC.h"
#import "WKCareListVC.h"
#import "WKVideoListVC.h"
#import "JXCategoryView.h"
#import "WKHomeBookListVC.h"

@interface WKStrategyListVC ()<UIScrollViewDelegate,JXCategoryViewDelegate>
@property(nonatomic,strong)NSArray *titles;
@property(nonatomic,strong)UIScrollView *scrollView;
@property(nonatomic,strong)JXCategoryTitleView *categoryView;
@end

@implementation WKStrategyListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self hideMyNaviBar];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.titles = @[@"日记", @"美说", @"视频",@"问答"];
    
    CGFloat  categoryViewHeight = NavBarHeight - StatusBarHeight;
    
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, categoryViewHeight, ScreenWidth, ScreenHeight-NavBarHeight-categoryViewHeight)];
    self.scrollView.delegate = self;
    self.scrollView.pagingEnabled = YES;
    self.scrollView.contentSize = CGSizeMake(ScreenWidth*4, 0);
    self.scrollView.bounces = NO;
    [self.view addSubview:self.scrollView];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    WKHomeBookListVC *vc1 = [[WKHomeBookListVC alloc] init];
    [self addChildViewController:vc1];
    vc1.view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight-NavBarHeight-categoryViewHeight);
    [self.scrollView addSubview:vc1.view];
    
    WKCareListVC *vc2 = [[WKCareListVC alloc] init];
    [self addChildViewController:vc2];
    vc2.view.frame = CGRectMake(ScreenWidth, 0, ScreenWidth, ScreenHeight-NavBarHeight-categoryViewHeight);
    [self.scrollView addSubview:vc2.view];
    
    WKVideoListVC *vc3 = [[WKVideoListVC alloc] init];
    [self addChildViewController:vc3];
    vc3.view.frame = CGRectMake(ScreenWidth*2, 0, ScreenWidth, ScreenHeight-NavBarHeight-categoryViewHeight);
    [self.scrollView addSubview:vc3.view];
    
    WKHomeBookListVC *vc4 = [[WKHomeBookListVC alloc] init];
    vc4.view.frame = CGRectMake(ScreenWidth*3, 0, ScreenWidth, ScreenHeight-NavBarHeight-categoryViewHeight);
    [self addChildViewController:vc4];
    [self.scrollView addSubview:vc4.view];
    
    
    self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, categoryViewHeight)];
    self.categoryView.titles = _titles;
    self.categoryView.backgroundColor = [UIColor whiteColor];
    self.categoryView.delegate = self;
    self.categoryView.titleSelectedColor = BACK_COLOR;
    self.categoryView.titleColor = UIColorFromHex(0x3C3C3C);
    self.categoryView.titleFont = PFSC_MediumFont(13);
    self.categoryView.titleColorGradientEnabled = NO;
    self.categoryView.titleLabelZoomEnabled = NO;
    
    JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
    lineView.indicatorLineViewColor = BACK_COLOR;
    lineView.indicatorLineWidth = 35;
    self.categoryView.indicators = @[lineView];
    self.categoryView.contentScrollView = self.scrollView;
    
    [self.categoryView addSubview:[WHFactory addLineWithFrame:CGRectMake(0, 43, ScreenWidth, 1)]];
    
    [self.view addSubview:self.categoryView];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
